package tay;

import java.io.IOException;

import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

public class ReadFile {
	public static void readFile(Path p, FileSystem fs) throws Exception {
		if (fs.exists(p)) {
			FSDataInputStream is = fs.open(p);
			FileStatus status = fs.getFileStatus(p);
			byte[] buffer = new byte[Integer.parseInt(String.valueOf(status.getLen()))];
			is.readFully(0, buffer);
			is.close();
			fs.close();
			System.out.println(buffer.toString());
		}

	}
}
